package com.asoft.examonline.exammanager.util;

import org.apache.log4j.Logger;

import com.asoft.common.basedata.model.Type;
import com.asoft.examonline.define.QuestionTypeCode;

/**
 * 代码
 * 
 * @author amon
 *
 */
public class CodeUtil
{
        static Logger logger = Logger.getLogger(CodeUtil.class);
        
        // 课题题型代码－>题型代码
        public static String subjectQuestTypeCode2QuestType(Type subjectQuestType)
        {
                int length = subjectQuestType.getCode().length();
                if(subjectQuestType.getCode().replaceAll(QuestionTypeCode.SIMPLE_SELECT,"").length() < length)
                {
                        return QuestionTypeCode.SIMPLE_SELECT;
                }
                if(subjectQuestType.getCode().replaceAll(QuestionTypeCode.MULTI_SELECT,"").length() < length)
                {
                        return QuestionTypeCode.MULTI_SELECT;
                }
                return QuestionTypeCode.SUBJECTIVE;
        }
        
        // 课题题型代码－》课题代码
        public static String subjectQuestTypeCode2SubjectCode(Type subjectQuestType)
        {
                return subjectQuestType.getSuperType().getCode().replaceAll("_QT", "");
        }
        
        // 学科－＞学科知识分类
        public static String SubjectCode2KnowLedgeTypeCode(Type subjectType)
        {
                return subjectType.getCode() + "_KT";
        }
}
